package pl.edu.pw.elka.jtrzasko.proz.warcaby.figures;

import java.io.Serializable;

import pl.edu.pw.elka.jtrzasko.proz.warcaby.model.Board;
import pl.edu.pw.elka.jtrzasko.proz.warcaby.model.Players;
import pl.edu.pw.elka.jtrzasko.proz.warcaby.model.Position;

public class King extends Figure implements Serializable
{
	public King(Position position, FigureColor color)
	{
		super(color, position);
	}

	public boolean isMoveValid(Position p2, Board board)
	{
		if (Math.abs(position.getXdiff(p2)) == Math.abs(position.getYdiff(p2)))
			if (Math.abs(position.getXdiff(p2)) > 0)
			if (board.isFieldsEmpty(position.getFieldsFromLine(p2)))
				return true;
		return false;
	}

	public boolean isBeatingValid(Position p2, Board board)
	{
		if (Math.abs(position.getXdiff(p2)) == Math.abs(position.getYdiff(p2))
				&& Math.abs(position.getYdiff(p2)) > 1)
			if (board.isFieldEmpty(p2)
					&& board.isFieldsContainsColor(position.getFieldsFromLine(p2), board
							.getFigure(position).getColor().nextColor())
					&& !board.isFieldsContainsDoubleFigure(position.getFieldsFromLine(p2)))
				return true;
		return false;
	}

	public boolean isPromotionValid(Board board)
	{
		return false;
	}


}
